/**
* @Title: PagingInterceptor.java
* @Package com.yly.common.basic.interceptors.struts
* @Description: TODO
* @author zz
* @date 2013-12-29 下午3:48:49
* @version V1.0
*/
package com.yly.common.suppor.interceptors.struts;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.yly.common.basic.interceptors.struts.BasicSupportInterceptor;
import com.yly.common.basic.pojo.PageParameter;
import com.yly.utils.StrUtil;
import com.yly.utils.ThreadLocalUtil;

/**
 * @ClassName: PagingInterceptor
 * @Description: TODO
 * @author zz
 * @date 2013-12-29 下午3:48:49
 */
public class PagingInterceptor extends BasicSupportInterceptor {
	
	protected String beforeExecute() {
		ActionInvocation actionInvocation = this.getActionInvocation();
		HttpServletRequest request = (HttpServletRequest) actionInvocation.getInvocationContext().get(ServletActionContext.HTTP_REQUEST);
		
		PageParameter page = new PageParameter();
		String currentPage = request.getParameter("_currentPage");
		if(!StrUtil.nil(currentPage)){
			page.setCurrentPage(Integer.parseInt(currentPage));
		}
		String pageSize = request.getParameter("_pageSize");
		if(!StrUtil.nil(pageSize)){
			page.setPageSize(Integer.parseInt(pageSize));
		}
		ThreadLocalUtil.set("param.pageParameter", page);
		ThreadLocalUtil.set("param.isPage", false);
		return null;
	}
}
